<style lang="less">
@import "@/styles/table-common.less";
.page{
  background-color: #fff;
  .ivu-tag{
    cursor: auto;
  }
}

</style> 
<template>
  <div class="page">
    <Tabs :animated="false">
        <TabPane label="人员管理"><Manage :scuid="scuid" /></TabPane>
        <TabPane label="员工消费查看"><Consumption :companyName="companyName" :uid="companyId" :expenseId="scuid" /></TabPane>
        <TabPane label="历史订单"><HistoryOrder :uid="companyId" /></TabPane>
        <TabPane label="门闸出入记录"><Latch :uCompanyId="companyId" /></TabPane>
        <TabPane label="个人消费查看"><Personage :scuid="scuid" /></TabPane>
    </Tabs>
  </div>
</template>

<script>
import Manage from './manage/manage'
import Consumption from './consumption/consumption'
import HistoryOrder from './history-order/history-order'
import Latch from './latch/latch'
import Personage from './personage/personage'
import {
  // getScInOutRule
} from "@/api/index";


export default {
  name: "user-manage",
  components: {
    // addEdit,
    Manage,
    Consumption,
    HistoryOrder,
    Latch,
    Personage
  },
  data() {
    return {
      loading: true,
      scuid: '',
      companyId: '',
      companyName: ''
      // expenseId: ''
    };
  },
  methods: {
    init() {
      // this.getDataList();
    },
   
    getDataList() {
      // 多条件搜索用户列表
      // this.loading = true;
      
    },
  },
  created() {
    console.log('this.$route.params',this.$route.params)
    if(Object.keys(this.$route.params).length>0) {
      this.scuid = this.$route.params.scuid //员工id
      this.companyId = this.$route.params.companyId
      this.companyName = this.$route.params.companyName
      localStorage.setItem('localStorage_scuid',JSON.stringify(this.$route.params.scuid))
      localStorage.setItem('localStorage_companyId',JSON.stringify(this.$route.params.companyId))
      localStorage.setItem('localStorage_companyName',JSON.stringify(this.$route.params.companyName))
    }else{
      this.scuid = JSON.parse(localStorage.getItem('localStorage_scuid'))
      this.companyId = JSON.parse(localStorage.getItem('localStorage_companyId'))
      this.companyName = JSON.parse(localStorage.getItem('localStorage_companyName'))
    }
  },
  mounted() {
    this.init();
  },
  watch: {
    $route: {
      handler() {
        if(Object.keys(this.$route.params).length>0) {
          this.scuid = this.$route.params.scuid //员工id
          this.companyId = this.$route.params.companyId
          this.companyName = this.$route.params.companyName
          localStorage.setItem('localStorage_scuid',JSON.stringify(this.$route.params.scuid))
          localStorage.setItem('localStorage_companyId',JSON.stringify(this.$route.params.companyId))
          localStorage.setItem('localStorage_companyName',JSON.stringify(this.$route.params.companyName))
        }else{
          this.scuid = JSON.parse(localStorage.getItem('localStorage_scuid'))
          this.companyId = JSON.parse(localStorage.getItem('localStorage_companyId'))
          this.companyName = JSON.parse(localStorage.getItem('localStorage_companyName'))
        }
      },
      deep: true,
    }
  }    
};
</script>